package com.yuebook.smartrpc.framework.cluster;

/**
 * @author honglei
 * @date 2018/11/20 上午10:44
 */
public enum ClusterStrategyEnum {
    CLUSTER_STRATEGY_RANDOM("random"),
    CLUSTER_STRATEGY_WEIGHT_RANDOM("weight_random"),
    CLUSTER_STRATEGY_POLLING("polling"),
    CLUSTER_STRATEGY_WEIGHT_POLLING("weight_polling"),
    CLUSTER_STRATEGY_HASH("hash"),
    ;

    private String type;

    ClusterStrategyEnum(String type) {
        this.type = type;
    }

    public String getType() {
        return type;
    }

    public static ClusterStrategyEnum queryByType(String type) {
        for (ClusterStrategyEnum en : ClusterStrategyEnum.values()) {
            if (en.getType().equals(type)) {
                return en;
            }
        }
        return null;
    }
}
